package com.kube.csv;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Element {
	private String value = null;
	
	public Element(String value) {
		this.value = value;
	}

	public String valueAsString() {
		return this.value;
	}
	
	public int valueAsInteger() {
		return new Integer(this.value).intValue();
	}
	
	public double valueAsDouble() {
		return new Double(this.value).doubleValue();
	}
	
	public Date valueAsDate(String format) {
		try {
			return new SimpleDateFormat(format).parse(this.value);
		} catch (ParseException e) {
			throw new RuntimeException("Cannot parse date with given format string!", e);
		}
	}
	
}
